import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'website_link.freezed.dart';
part 'website_link.g.dart';

@freezed
abstract class CreateWebsiteLinkRequest with _$CreateWebsiteLinkRequest {
  const factory CreateWebsiteLinkRequest({
    required String title,
    required String description,
    required String url,
  }) = _CreateWebsiteLinkRequest;
  factory CreateWebsiteLinkRequest.fromJson(Map<String, Object?> json) => _$CreateWebsiteLinkRequestFromJson(json);
}

@freezed
abstract class UpdateWebsiteLinkRequest with _$UpdateWebsiteLinkRequest {
  const factory UpdateWebsiteLinkRequest({
    required int id,
    String? title,
    String? description,
    String? url,
  }) = _UpdateWebsiteLinkRequest;
  factory UpdateWebsiteLinkRequest.fromJson(Map<String, Object?> json) => _$UpdateWebsiteLinkRequestFromJson(json);
}

@freezed
abstract class WebsiteLink with _$WebsiteLink {
  // 从api返回的数据
  const factory WebsiteLink({
    required int id,
    required String title,
    required String description,
    required String url,
    required String createTime,
  }) = _WebsiteLink;

  factory WebsiteLink.fromJson(Map<String, Object?> json) => _$WebsiteLinkFromJson({ ...json, 'createTime': json['createTime'] ?? json['create_time'] });
}
